package com.vm.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;

import com.vm.activity.ShakeActivity;
import com.vm.activity.SignActivity;
import com.wwt.app.R;

public class ActiveFragment extends BaseFragment{

	RelativeLayout rlayout_sign;
	RelativeLayout rlayout_shake;
	private View view;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		Log.i("ManagerFragment", "onCreateView");

		if (view == null) {
			view = inflater.inflate(R.layout.activity, null);
		} else {
			// 缓存的rootView需要判断是否已经被加过parent
			// 如果有parent需要从parent删除
			ViewGroup parent = (ViewGroup) view.getParent();
			if (parent != null) {
				parent.removeView(view);
			}
		}
		return view;
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);

		rlayout_sign = (RelativeLayout) view.findViewById(R.id.rlayout_sign);
		rlayout_sign.setOnClickListener(rlayout_ClickListener);

		rlayout_shake = (RelativeLayout) view.findViewById(R.id.rlayout_shake);
		rlayout_shake.setOnClickListener(rlayout_ClickListener);

	}

	OnClickListener rlayout_ClickListener = new OnClickListener() {

		@Override
		public void onClick(View v) {
			if (v == rlayout_sign) {
				Intent intent = new Intent(getActivity(), SignActivity.class);
				startActivity(intent);
			}
			else if(v==rlayout_shake){
				Intent intent = new Intent(getActivity(), ShakeActivity.class);
				startActivity(intent);
			}
		}
	};
	
	@Override
	protected void lazyLoad() {
		// TODO Auto-generated method stub
		
	}

}
